using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;

public class CircleGenerator : MonoBehaviour
{
    public GameObject m_CirclePrefab;
    public TextMeshProUGUI m_NumberText;
    List<SDFShape>  m_Shapes = new List<SDFShape>();
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKey(KeyCode.Space))
        {
            var circle = Instantiate(m_CirclePrefab);
            circle.GetComponent<SDFShape>().Color = new Color(UnityEngine.Random.Range(0f, 1f), UnityEngine.Random.Range(0f, 1f), UnityEngine.Random.Range(0f, 1f));
            // circle.GetComponent<SpriteRenderer>().color = new Color(UnityEngine.Random.Range(0f, 1f), UnityEngine.Random.Range(0f, 1f), UnityEngine.Random.Range(0f, 1f));
            circle.transform.position = transform.position;
            circle.GetComponent<Rigidbody2D>().AddForce(Vector2.right * 10f, ForceMode2D.Impulse);
            m_NumberText.text = m_Shapes.Count.ToString();
            m_Shapes.Add(circle.GetComponent<SDFShape>());
        }
    }

    public void Clear()
    {
        foreach (var i in m_Shapes)
        {
            Destroy(i.gameObject);
        }
        m_Shapes.Clear();
    }
}
